<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>vue组件5</title>
    <script src="../../js/vue3.js"></script>
    <style>
        #app {
            margin: 2rem auto;
            width: 30%;
        }

        p {
            font-size: 1.5rem;
            font-weight: bold;
        }
    </style>
</head>

<body>
    <div id="app">
        <btn-click1></btn-click1>
        <hr>
        <btn-click1></btn-click1>
        
    </div>
    <template id="btn1">
        <p> 学校名称: {{schoolName}}</p>
        <p> 学校地址: {{address}}</p>
        <p><button @click="bounce1()">弹出校名</button></p>
        <p> 学生姓名: {{studentName}}</p>
        <p> 学生年龄: {{studentBorn}}</p>
        <p><button @click="bounce2()">弹出校出生日期</button></p>
    </template>
    <script>
        const v_app = Vue.createApp({
            data() {
                return {

                }
            },
            components: {
                BtnClick1: {
                    data() {
                        return {
                            schoolName: "河北科工大",
                            address:"邢台",
                            studentName:"小明",
                            studentBorn:"18",
                        }
                    },
                    template: "#btn1",
                    methods:{
                        bounce1(){
                            return alert(this.schoolName);
                        },
                        bounce2(){
                            let time = new Date();
                            let year = time.getFullYear();
                            return  alert(year - this.studentBorn);
                        }
                    }
                },
            }
        });

        v_app.mount("#app");
    </script>
</body>

</html>